// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import FastClick from 'fastclick'
import VueRouter from 'vue-router'
import App from './App'
import router from './router/index.js'
import Vuex from 'vuex'
import axios from 'axios'
import vuexI18n from 'vuex-i18n';

Vue.use(VueRouter)
Vue.use(Vuex);
const store = new Vuex.Store({  
    modules: {  
        i18n: vuexI18n.store  
    }  
});  
Vue.use(vuexI18n.plugin, store);  
const translationsEn = {  
    "content": "This is some {type} content"  
};  
  
Vue.i18n.add('en', translationsEn);  
Vue.i18n.set('en');  
import  { LoadingPlugin,ToastPlugin   } from 'vux'
Vue.use(LoadingPlugin)
Vue.use(ToastPlugin  );

/** vux弹框遮罩层封装 */
Vue.prototype.showLoading = function(text){
    this.$vux.loading.show({
        text:text
    });
}
Vue.prototype.hideLoading = function(){
    this.$vux.loading.hide();
}

Vue.prototype.toastMsg = function(content,type){
    if( !type ){
        type = "text";
    }
    this.$vux.toast.show({
        text : content,
        type : type
    });
}


//设置cookie,增加到vue实例方便全局调用
Vue.prototype.setCookie = (c_name, value, expiredays) => {
  var exdate = new Date();　　　　
  exdate.setDate(exdate.getDate() + expiredays);　　　　
  document.cookie = c_name + "=" + escape(value) + ((expiredays == null) ? "" : ";expires=" + exdate.toGMTString());
}

//获取cookie
Vue.prototype.getCookie = (name) => {
    var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
    if (arr = document.cookie.match(reg))
        return (arr[2]);
    else
        return null;
}

//删除cookie
Vue.prototype.delCookie =(name) => {
    var exp = new Date();
    exp.setTime(exp.getTime() - 1);
    var cval = this.getCookie(name);
    if (cval != null)
      document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString();
  }



Vue.prototype.$http = axios.create({
    baseURL: 'http://mcbcs.jiangti.com.cn/maotu/core/api.php/rizhi',
    //baseURL:"http://192.168.2.100/myprojet/api.php/rizhi",
    timeout: 1000,
    headers:{Accept:'application/json'}
  });

FastClick.attach(document.body)

Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
  router,
  render: h => h(App)
}).$mount('#app-box')
